#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
THN WEB SERVER

Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

This library is dual-licensed.
  + For use in commercial software, please obtain a commercial license from THN Solutions LLC.    

  + For use in free software, this library is licensed under GPL version 3. A summary of 
	GPLv3 is listed below. You should also find a copy of GPLv3 as file License_GPLv3.txt 
	included with the source-code files.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 3 as published by
    the Free Software Foundation  of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#endregion

#region Record of Change
//             							CHANGE HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | DEVELOPER  | DESCRIPTION                                              |
// -------------------------------------------------------------------------------------
// | 14-Nov-12 | HaiNM      | First creation.                                          |
// -------------------------------------------------------------------------------------
//
#endregion

#region Record of Audit
//             							REVIEW HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | REVIEWER   | NOTES                                                    |
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
//
#endregion

#region Using directives
using System;

using Thn;
using Thn.Collections;
#endregion

namespace Thn.Web
{
    /// <summary>
    /// Default implementation of <see cref="IMimeTypes"/>.
    /// </summary>
#if DEBUG || TESTING
    public
#else
    internal
#endif
 class MimeTypes : StringDictionary<string>, IMimeTypes
    {
        #region Fields
        #endregion

        #region Properties
        #endregion

        #region Add Default Mime Types

        /// <summary>
        /// Mime types that this class can handle per default
        /// </summary>
        /// <remarks>
        /// Contains the following mime types:
        /// <list type="table">
        /// <item><term><![CDATA[txt]]></term><value><![CDATA[text/plain]]></value></item>
        /// <item><term><![CDATA[html]]></term><value><![CDATA[text/html]]></value></item>
        /// <item><term><![CDATA[htm]]></term><value><![CDATA[text/html]]></value></item>
        /// <item><term><![CDATA[jpg]]></term><value><![CDATA[image/jpg]]></value></item>
        /// <item><term><![CDATA[jpeg]]></term><value><![CDATA[image/jpg]]></value></item>
        /// <item><term><![CDATA[bmp]]></term><value><![CDATA[image/bmp]]></value></item>
        /// <item><term><![CDATA[gif]]></term><value><![CDATA[image/gif]]></value></item>
        /// <item><term><![CDATA[png]]></term><value><![CDATA[image/png]]></value></item>
        /// <item><term><![CDATA[ico]]></term><value><![CDATA[image/vnd.microsoft.icon]]></value></item>
        /// <item><term><![CDATA[css]]></term><value><![CDATA[text/css]]></value></item>
        /// <item><term><![CDATA[gzip]]></term><value><![CDATA[application/x-gzip]]></value></item>
        /// <item><term><![CDATA[zip]]></term><value><![CDATA[multipart/x-zip]]></value></item>
        /// <item><term><![CDATA[tar]]></term><value><![CDATA[application/x-tar]]></value></item>
        /// <item><term><![CDATA[pdf]]></term><value><![CDATA[application/pdf]]></value></item>
        /// <item><term><![CDATA[rtf]]></term><value><![CDATA[application/rtf]]></value></item>
        /// <item><term><![CDATA[xls]]></term><value><![CDATA[application/vnd.ms-excel]]></value></item>
        /// <item><term><![CDATA[ppt]]></term><value><![CDATA[application/vnd.ms-powerpoint]]></value></item>
        /// <item><term><![CDATA[doc]]></term><value><![CDATA[application/application/msword]]></value></item>
        /// <item><term><![CDATA[js]]></term><value><![CDATA[application/javascript]]></value></item>
        /// <item><term><![CDATA[au]]></term><value><![CDATA[audio/basic]]></value></item>
        /// <item><term><![CDATA[snd]]></term><value><![CDATA[audio/basic]]></value></item>
        /// <item><term><![CDATA[es]]></term><value><![CDATA[audio/echospeech]]></value></item>
        /// <item><term><![CDATA[mp3]]></term><value><![CDATA[audio/mpeg]]></value></item>
        /// <item><term><![CDATA[mp2]]></term><value><![CDATA[audio/mpeg]]></value></item>
        /// <item><term><![CDATA[mid]]></term><value><![CDATA[audio/midi]]></value></item>
        /// <item><term><![CDATA[wav]]></term><value><![CDATA[audio/x-wav]]></value></item>
        /// <item><term><![CDATA[swf]]></term><value><![CDATA[application/x-shockwave-flash]]></value></item>
        /// <item><term><![CDATA[avi]]></term><value><![CDATA[video/avi]]></value></item>
        /// <item><term><![CDATA[rm]]></term><value><![CDATA[audio/x-pn-realaudio]]></value></item>
        /// <item><term><![CDATA[ram]]></term><value><![CDATA[audio/x-pn-realaudio]]></value></item>
        /// <item><term><![CDATA[aif]]></term><value><![CDATA[audio/x-aiff]]></value></item>
        /// </list>
        /// </remarks>
        public void AddDefaultMimeTypes()
        {
            //this.Add("default", "application/octet-stream");
            this.Add("default", "text/html");
            this.Add(".txt", "text/plain");
            this.Add(".html", "text/html");
            this.Add(".htm", "text/html");
            this.Add(".jpg", "image/jpg");
            this.Add(".jpeg", "image/jpg");
            this.Add(".bmp", "image/bmp");
            this.Add(".gif", "image/gif");
            this.Add(".png", "image/png");

            this.Add(".ico", "image/vnd.microsoft.icon");
            this.Add(".css", "text/css");
            this.Add(".gzip", "application/x-gzip");
            this.Add(".zip", "multipart/x-zip");
            this.Add(".tar", "application/x-tar");
            this.Add(".pdf", "application/pdf");
            this.Add(".rtf", "application/rtf");
            this.Add(".xls", "application/vnd.ms-excel");
            this.Add(".ppt", "application/vnd.ms-powerpoint");
            this.Add(".doc", "application/msword");
            this.Add(".js", "application/javascript");
            this.Add(".au", "audio/basic");
            this.Add(".snd", "audio/basic");
            this.Add(".es", "audio/echospeech");
            this.Add(".mp3", "audio/mpeg");
            this.Add(".mp2", "audio/mpeg");
            this.Add(".mid", "audio/midi");
            this.Add(".wav", "audio/x-wav");
            this.Add(".swf", "application/x-shockwave-flash");
            this.Add(".avi", "video/avi");
            this.Add(".rm", "audio/x-pn-realaudio");
            this.Add(".ram", "audio/x-pn-realaudio");
            this.Add(".aif", "audio/x-aiff");

            //videos
            this.Add(".flv", "video/x-flv");
            //this.Add(".m4v", "video/mp4"); //doesn't work for old Android devices
            this.Add(".m4v", "video/x-m4v");
            this.Add(".m3u", "audio/x-mpegurl");
            this.Add(".m1v", "video/mpeg");
            this.Add(".mp4", "video/mp4");
            this.Add(".ogg", "video/ogg");
            this.Add(".ogm", "video/ogg");
            this.Add(".ogv", "video/ogg");
            this.Add(".webm", "video/webm");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
            //this.Add(".", "");
        }

        #endregion

        #region Constructors
        /// <summary>
        /// Default constructor.
        /// </summary>
        public MimeTypes()
            : base()
        {
            AddDefaultMimeTypes();
        }
        #endregion
    }
}
